<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--<link href="/admin/layui/css/layui.css">-->
    <link rel="stylesheet" href="/codemirror-5.42.0/lib/codemirror.css">
</head>
<body>
<table>
    当前路径：<% if(has(err)){ %>
        ${err}
   <% }else{ %>
    ${current_path}
    <% } %>

    <%
    if(has(dir)){
        for(f in dir){ %>
        <tr>
            <td>目录：<a href="/file?path=${f.dirPath}">${f.dirName}</a></td>
        </tr>
    <% } }%>

    <%
    if(has(file)){
    for(e in file){ %>
    <tr>
        <td>文件：<a href="/file?path=${e.filePath}">${e.fileName}</a> <span> 大小：${e.fileSize}</span> <span> 修改时间：${e.fileTime}</span> <span> 相对路径：${e.filePath}</span></td>
    </tr>
    <% } }%>

    <%
     if(has(centent)){ %>
    <br /><textarea class="form-control" id="code" name="code">${centent}</textarea>
    <button onclick="console.log(editor.getValue());">获取编辑器内容</button>
    <script type="text/javascript" src="/codemirror-5.42.0/lib/codemirror.js"></script>
    <script src="/codemirror-5.42.0/mode/javascript/javascript.js"></script>
    <script type="text/javascript">
        //根据DOM元素的id构造出一个编辑器
        var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
            lineNumbers:true,
            mode:  "javascript",
            lineWrapping: true, //代码折叠
            matchBrackets: true,    //括号匹配
            readOnly: false   //只读外 nocursor不能获取焦点
        });
        editor.setSize('800px', '500px'); //设置代码框的长宽
    </script>
    <% } %>

</table>
</body>
</html>